package com.billing.web.controller.common;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class RequestUtils {
	/**
	 * 获得POST 过来参数设置到新的params中
	 * @param requestParams
	 * 			POST 过来参数Map
	 * @return
	 * 			新的Map
	 */
	public static Map<String, String> genMapByRequestParas(Map requestParams){
		
		Map<String, String> params = new HashMap<String, String>();
		for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
			String name = (String) iter.next();
			String[] values = (String[]) requestParams.get(name);
			String valueStr = "";
			for (int i = 0; i < values.length; i++) {
				valueStr = (i == values.length - 1) ? valueStr + values[i]
						: valueStr + values[i] + ",";
			}
			
			if(valueStr.isEmpty()) continue;
			
			params.put(name, valueStr);
		}
		
		return params;
		
	}
}
